import { fileURLToPath, URL } from 'node:url'
// import path from 'path'
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import AutoImport from 'unplugin-auto-import/vite'
import Components from 'unplugin-vue-components/vite'
import { ElementPlusResolver } from 'unplugin-vue-components/resolvers'


export default defineConfig({
  server: {
    host: '0.0.0.0',
    port:3000
  },
  base: './',
  plugins: [
    vue(),
    AutoImport({
      resolvers: [ElementPlusResolver()],
    }),
    Components({
      resolvers: [ElementPlusResolver()],
    }),
  ],
  resolve: {
    alias: {
      '@': fileURLToPath(new URL('./src', import.meta.url))
    }
  },
  // postcss: {
  //   plugins: [
  //     require('postcss-pxtorem')({
  //       rootValue: 54,
  //       propList: ['*']
  //     })
  //   ]
  // },
  css: {
    // scss全局变量的设置
    preprocessorOptions: {
      scss: {
        // javascriptEnabled: true,
        additionalData: `@use "./src/styles/variable.scss" as *;`,
      },
    },
    loaderOptions:{
      postcss:{
        postcssOptions:{
          plugins: [
            require('postcss-pxtorem')({
              rootValue:192,
              propList: ['*']
            })
          ]
        }
      }
    }
  },
})
